package com.study_platform.consumer;

import com.study_platform.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.websocket.*;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;

@Component
@ServerEndpoint("/websocket/{token}")
public class WebSocketServer {


    private static UserMapper userMapper;

    @Resource
    public void setUserMapper(UserMapper userMapper) {
        WebSocketServer.userMapper = userMapper;
    }

    @OnOpen
    public void onOpen(Session session, @PathParam("token") String token) {

    }

    @OnClose
    public void onClose(){

    }

    @OnMessage
    public void onMessage(String message, Session session){

    }

    @OnError
    public void onError(Session session, Throwable error){
        error.printStackTrace();
    }
}